<style type="text/css">
	.mail_templates .btn { margin: 7px 0 0; }
</style>

<h4>Памятка: </h4>
<b>%username%</b> в теле письма заменяется на имя пользователя, которому будет выслано письмо. <br />
<b>%order%</b> будет заменен на номер заказа и ссылку на него. <br />
<b>%items%</b> будет заменен на список товаров в заказе. <br />

<?php foreach ($this->mailTemplates as $mtp):?>
	<h2><?=$mtp->title?></h2>
	<form action="<?=$this->baseUrl . '/admin/mailTemplate/save/id/' . $mtp->id?>" method="post" class="mail_templates">
		<input type="text" class="input wide" name="mail_title" placeholder="Заголовок письма" value="<?=$mtp->mail_title?>">
		<textarea class="ckeditor wide" placeholder="Текст письма" name="body" id="<?=$mtp->id?>"><?=$mtp->body?></textarea>
		<input type="submit" class="btn btn-green" value="Сохранить">
	</form>
<?php endforeach?>

<script type="text/javascript">
	$(function() {
		<?php foreach($this->mailTemplates as $mtp):?>
		CKEDITOR.replace( '<?=$mtp->id?>',
			{
				filebrowserBrowseUrl :'<?=$this->baseUrl?>/js/ckeditor/filemanager/browser/default/browser.html?Connector=<?=$this->baseUrl?>/js/ckeditor/filemanager/connectors/php/connector.php',
				filebrowserImageBrowseUrl : '<?=$this->baseUrl?>/js/ckeditor/filemanager/browser/default/browser.html?Type=Image&Connector=<?=$this->baseUrl?>/js/ckeditor/filemanager/connectors/php/connector.php',
				filebrowserFlashBrowseUrl :'<?=$this->baseUrl?>/js/ckeditor/filemanager/browser/default/browser.html?Type=Flash&Connector=<?=$this->baseUrl?>/js/ckeditor/filemanager/connectors/php/connector.php',
				filebrowserUploadUrl  :'<?=$this->baseUrl?>/js/ckeditor/filemanager/connectors/php/upload.php?Type=File',
				filebrowserImageUploadUrl : '<?=$this->baseUrl?>/js/ckeditor/filemanager/connectors/php/upload.php?Type=Image',
				filebrowserFlashUploadUrl : '<?=$this->baseUrl?>/js/ckeditor/filemanager/connectors/php/upload.php?Type=Flash'
			});
		<?php endforeach?>
	});
</script>